#include "opt.h"


/*
 * edt: soptarg
 *
 * see opt.h for details
 */
char *soptarg = NULL;


/*
 * edt: sgetopt()
 *
 * see opt.h for details
 */
char *
sgetopt(int argc, char *argv[], int *index)
{
    char *curr = NULL;
    char *next = NULL;
    soptarg = NULL;

    if (*index < argc) {
        curr = argv[*index];
        if (curr != NULL && *curr == '-' && strlen(curr) > 1) {
            if (*index < argc - 1) {
                next = argv[*index + 1];
            }
            if (next != NULL  && *next != '-') {
                soptarg = next;
                (*index)++;
            }
            curr++;
            (*index)++;
        } else {
           /*
            * Option processing error
            */
            curr = NULL;
        }
    }

    return curr;
}

